Repository navigation
Make detailed find agree with info on duplicate Drive paths - #422
Merged
Merged
Conversation
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues remain for the changes aligning duplicate-path listing metadata with info().
No open issues 🎉
What changed in this PR
This PR addresses #421 by making detailed Drive filesystem listings select duplicate-path metadata consistently with info(), while preserving traversal through every matching folder.
Changes:
- Selects the lowest eligible Drive ID for duplicate paths, including file/folder collisions when directories are requested.
- Groups children by logical parent path and tracks ID preferences only for repeated names.
- Adds regression tests for cold and warm caches, pagination, and starting-path collisions, and documents the behavior.
| File | Description |
|---|---|
pydrive2/test/test_fs_unit.py |
Adds duplicate-path selection and traversal regression tests. |
pydrive2/fs/spec.py |
Implements deterministic metadata selection across duplicate paths. |
docs/fsspec.rst |
Documents ID selection and traversal of matching folders. |
Review effort: Balanced
shcheklein
commented
Nov 30, 2026
shcheklein
left a comment
Member
Author
There was a problem hiding this comment.
LGTM — no blocking issues found. Per-path grouping in _walk_folders, duplicate-only tie-breaking in _preferred_ids, and folders_only=not (withdirs and detail) integrate cleanly with DirectoryCache while keeping memory overhead minimal. Left a few minor non-blocking notes inline.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #421.
If two Drive items share a path,
find(withdirs=True, detail=True)now reports the item with the lowest Drive ID, just asinfo()does. All matching folders still contribute descendants, including when a file supplies the metadata for their shared path. Files-only detailed searches choose the lowest eligible file ID.The walk compares siblings from all physical folders at each logical path. It sorts temporary references for that directory and records an ID preference only for repeated names. Individual file IDs do not enter the filesystem cache.
Verification
Public filesystem tests cover cold and warm duplicate ancestors, both outcomes of a file/folder collision, a collision at the starting path, and three same-name files split across response pages. The warm reproduction uses one Drive listing. The cold reproduction uses four.
The offline suite passed (333 passed, 2 skipped). Ruff, mypy and the Sphinx build with warnings treated as errors passed.
Simulated listing performance
Cold
find("root", withdirs=True, detail=True)over 262,144 files on Python 3.12 with a paginated in-process Drive transport. Each figure is the median of three fresh processes per revision, compared with0104333.